<?php

class ServicesLog extends BaseEntity {
	function __construct($id = 0){
		parent::__construct($id);
	}
	
	static function log($service, $params){
		$log = new ServicesLog();
		$log->datetime = date("Y-m-d H:i:s");
		$log->service = $service;
		$log->params = json_encode($params);
		$log->response = "The response was never called or the service has failed.";
		$log->save(false, false, false);
		return $log->id;
	}
	
	static function logResponse($serviceLogId, $response){
		$log = new ServicesLog($serviceLogId);
		if (empty($log->response)) {
			$log->response = $response;
			$log->save(false, false, false);
		}
	}
}